package top.zuli.package01.class14;

public class WindowTest1 {
    public static void main(String[] args) {
        Runnable runnable = new Window1();
        Thread thread1 = new Thread(runnable);
        thread1.start();
        Thread thread2 = new Thread(runnable);
        thread2.start();
        Thread thread3 = new Thread(runnable);
        thread3.start();
    }
}
class Window1 implements  Runnable{
    private int ticket = 100;
    @Override
    public void run() {
        while(true){
            if (ticket>0){
                System.out.println(Thread.currentThread().getName()+"卖票,票号："+ticket);
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                ticket--;
            }else {
                break;
            }
        }
    }
}
